package com.city.service.party.impl;

import com.city.domain.party.PartyLesson;
import com.city.repository.party.PartyLessonRepository;
import com.city.service.party.PartyLessonService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class PartyLessonServiceImpl implements PartyLessonService{


    @Autowired
    private PartyLessonRepository lessonRepository;
    @Override
    public void save(PartyLesson partyLesson) {
        lessonRepository.save(partyLesson);
    }

    @Override
    public List<PartyLesson> findByPage(Integer page, Integer limit) {
        return lessonRepository.findAllByPage((page-1)*limit,limit);
    }

    @Override
    public long count() {
        return lessonRepository.count();
    }

    @Override
    public PartyLesson findById(int id) {
        return lessonRepository.findOne(id);
    }

    @Override
    public List<PartyLesson> findAll() {
        return lessonRepository.findAll();
    }

    @Override
    public PartyLesson findByName(String name) {
        return lessonRepository.findByName(name);
    }

    @Override
    public List<PartyLesson> findByTimeSort() {
        return lessonRepository.findByTimeSort();
    }

    @Override
    public void deleteLesson(Integer id) {
        lessonRepository.delete(id);
    }
}
